package com.gcxy.controller;


import com.gcxy.dto.Fence.InsertDto;
import com.gcxy.dto.Fence.UpdateDto;
import com.gcxy.entity.Fence;
import com.gcxy.service.FenceService;
import com.gcxy.utils.R;
import com.gcxy.vo.Fence.FenceVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wlp
 * @since 2023-12-19
 */
@RestController
@RequestMapping("/fence")
@Api(tags = "围栏管理")
public class FenceController {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private FenceService fenceService;
    @ApiOperation("围栏新增")
    @PostMapping("insert")
    public R fenceInsert(@Valid @RequestBody InsertDto requestBody){
        logger.info("正在围栏新增");
        R result=fenceService.fenceInsert(requestBody);
        return result;
    }
    @ApiOperation("围栏分页查询")
    @PostMapping("page")
    public R fencePage(@RequestBody FenceVo requestBody){
        logger.info("正在围栏分页查询");
        R result=fenceService.fencePage(requestBody);
        return result;
    }
    @ApiOperation("围栏修改")
    @PutMapping("update")
    public R fenceUpdate(@Valid @RequestBody UpdateDto requestBody){
        logger.info("正在围栏修改");
        R result=fenceService.fenceUpdate(requestBody);
        return result;
    }
    @ApiOperation("修改围栏状态")
    @PutMapping("updateState/{fenceId}/{fenceState}")
    public R fenceUpdateState(@PathVariable Integer fenceId,@PathVariable Integer fenceState){
        logger.info("正在围栏状态修改");
        R result=fenceService.fenceUpdateState(fenceId,fenceState);
        return result;
    }
}

